﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace GuiLayer
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        // uit voorbeeld MVVM WITH MUSIC STORE (wpf databindings)
      

        private static DataTable klanten_gegevens;
        private static SqlDataAdapter klanten_adapter;

        public static DataTable Klanten
        {
            get
            {
                if (klanten_gegevens == null)
                {
                    DataSet dataSet = new DataSet();
                    string mdfFile = @"BPCars";
                    //Data Source=.\sqlexpress;Initial Catalog=NORTHWND.MDF;Integrated Security=True
                    string connString = String.Format("Data Source=(localdb)\\v11.0;Initial Catalog={0};Integrated Security=True", mdfFile);
                    SqlConnection conn = new SqlConnection(connString);
                    klanten_adapter = new SqlDataAdapter();
                    klanten_adapter.SelectCommand = new SqlCommand("SELECT [Klanten].* FROM [Klanten]", conn);
                    klanten_adapter.Fill(dataSet, "Klanten");
                    klanten_gegevens = dataSet.Tables["Klanten"];
                }

                return klanten_gegevens;
            }
        }

        private static DataTable wagens_gegevens;
        private static SqlDataAdapter wagens_adapter;

        public static DataTable Wagens
        {
            get
            {
                if (wagens_gegevens == null)
                {
                    DataSet dataSet = new DataSet();
                    string mdfFile = @"BPCars";
                    //Data Source=.\sqlexpress;Initial Catalog=NORTHWND.MDF;Integrated Security=True
                    string connString = String.Format("Data Source=(localdb)\\v11.0;Initial Catalog={0};Integrated Security=True", mdfFile);
                    SqlConnection conn = new SqlConnection(connString);
                    wagens_adapter = new SqlDataAdapter();
                    wagens_adapter.SelectCommand = new SqlCommand("SELECT [Voertuig].* FROM [Voertuig]", conn);
                    wagens_adapter.Fill(dataSet, "Voertuig");
                    wagens_gegevens = dataSet.Tables["Voertuig"];
                }

                return wagens_gegevens;
            }
        }


    }
}